package com.xjx.pojo.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.*;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@Accessors(chain = true)
@TableName("user_account")
public class UserAccount implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 自增主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 用户名
     */
    @NotBlank(message = "用户名不能为空")
    @Size(max = 50, message = "用户名长度不能超过50")
    private String username;

    /**
     * 密码 (新增字段)
     */
    @NotBlank(message = "密码不能为空")
    @Size(max = 255, message = "密码长度过长")
    private String password;

    /**
     * 昵称
     */
    @Size(max = 50, message = "昵称长度不能超过50")
    private String nickname;

    /**
     * 邮箱
     */
    @Email(message = "邮箱格式不正确")
    @Size(max = 100, message = "邮箱长度不能超过100")
    private String email;

    /**
     * 手机号
     */
    @Size(max = 20, message = "手机号长度不能超过20")
    private String phone;

    /**
     * 头像URL (新增字段)
     */
    @Size(max = 255, message = "头像URL长度不能超过255")
    private String avatarUrl;

    /**
     * 状态:1-启用,0-禁用(默认启用)
     */
    @Min(value = 0)
    @Max(value = 1)
    private Integer status;

    /**
     * 逻辑删除:1-已删除,0-未删除(默认未删除)
     */
    @TableLogic(value = "0", delval = "1") // [cite: 977]
    private Integer deleted;

    /**
     * 乐观锁版本号 (新增字段)
     */
    @Version // [cite: 988]
    private Integer version;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(fill = FieldFill.INSERT) // [cite: 999]
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(fill = FieldFill.INSERT_UPDATE) // [cite: 1012]
    private LocalDateTime updateTime;
}